package com.ymliang.controller;

import com.ymliang.consumer.RabbitReceiver;
import com.ymliang.producer.RabbitSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@RestController
public class HelloController {

    @Autowired
    private RabbitSender rabbitSender;

    @RequestMapping("/v1/api")
    public String Hello() throws Exception {
        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put("number", "12345");
        properties.put("send_time", new SimpleDateFormat().format(new Date()));
        rabbitSender.send("Hello RabbitMQ For Spring Boot222!",properties);

        return "hello";
    }

}
